package proxy.a1_jdkproxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class JDKProxy {

	public static <T> T getProxy(Class clazz) {
		ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
		return (T) Proxy.newProxyInstance(contextClassLoader, new Class[]{clazz},
				new InvocationHandler() {
					public Object invoke(Object proxy, Method method, Object[] args) {
						System.out.println(method.getName() + "被代理了！");
						return null;
					}
				});
	}

}
